Coercion of Parameters
If a parameter doesn't belong to the right class, it may be possible to coerce it, that is, to change it into a value of another class. For example, you can coerce an integer such as 2 to the corresponding string"2"
using the As operator:
2 as stringAppleScript performs some coercions, including the previous one, automatically. For example, in the following statement, the direct parameter of the Copy command should be a string because it is being inserted into a text
editor document.
tell application "Scriptable Text Editor" copy 12 to beginning of document "Introduction"end tellWhen AppleScript executes this statement, it automatically coerces the integer 12 to the string"12"
and inserts the string at the beginning of the document.The coercions that AppleScript can perform are listed in Chapter 3, "Values." Applications can also perform additional coercions, such as coercions for classes that are specific to an application. These coercions are listed in the documentation for the application.